home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plmtex.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  4KB  |  104 lines

  1. /* Prints out "text" at specified position relative to viewport       */
  2. /* (may be inside or outside)                                         */
  3.  
  4. /* side   String which is one of the following:                       */
  5. /*        B or b  :  Bottom of viewport                               */
  6. /*        T or t  :  Top of viewport                                  */
  7. /*        L or l  :  Left of viewport                                 */
  8. /*        R or r  :  Right of viewport                                */
  9. /*        LV or lv : Left of viewport, vertical text                  */
  10. /*        RV or rv : Right of viewport, vertical text                 */
  11. /* disp   Displacement from specified edge of viewport, measured      */
  12. /*         outwards from the viewport in units of the current         */
  13. /*         character height. The CENTRELINES of the characters are    */
  14. /*         aligned with the specified position.                       */
  15. /* pos    Position of the reference point of the string relative      */
  16. /*         to the viewport edge, ranging from 0.0 (left-hand edge)    */
  17. /*         to 1.0 (right-hand edge)                                   */
  18. /* just   Justification of string relative to reference point         */
  19. /*         just = 0.0 => left hand edge of string is at reference     */
  20. /*         just = 1.0 => right hand edge of string is at reference    */
  21. /*         just = 0.5 => centre of string is at reference             */
  22.  
  23. #include "plplot.h"
  24.  
  25. void plmtex(side,disp,pos,just,text)
  26. char side[], text[];
  27. float disp, pos, just;
  28. {
  29.       int clpxmi, clpxma, clpymi, clpyma;
  30.       int sppxmi, sppxma, sppymi, sppyma;
  31.       int vert, refx, refy;
  32.       float shift, xform[4];
  33.       float vpdxmi, vpdxma, vpdymi, vpdyma;
  34.       float chrdef, chrht;
  35.       float mpxscl, mpxoff, mpyscl, mpyoff;
  36.  
  37.       int level;
  38.       glev(&level);
  39.       if (level < 2) fatal("Please set up viewport before calling PLMTEX.");
  40.       
  41.       /* Open clip limits to subpage limits */
  42.  
  43.       gclp(&clpxmi,&clpxma,&clpymi,&clpyma);
  44.       gspp(&sppxmi,&sppxma,&sppymi,&sppyma);
  45.       sclp(sppxmi,sppxma,sppymi,sppyma);
  46.  
  47.       gvpd(&vpdxmi,&vpdxma,&vpdymi,&vpdyma);
  48.       gmp(&mpxscl,&mpxoff,&mpyscl,&mpyoff);
  49.       gchr(&chrdef,&chrht);
  50.  
  51.       shift = 0.0;
  52.       if (just!=0.0) shift = just * plstrl(text);
  53.  
  54.       if (strpos(side,'B')!=-1 || strpos(side,'b')!=-1) {
  55.         vert = 0;
  56.         refx = dcpcx(vpdxmi + (vpdxma-vpdxmi) * pos) - shift*mpxscl;
  57.         refy = mmpcy(dcmmy(vpdymi) - disp * chrht);
  58.       }
  59.       else if (strpos(side,'T')!=-1 || strpos(side,'t')!=-1) {
  60.         vert = 0;
  61.         refx = dcpcx(vpdxmi + (vpdxma-vpdxmi) * pos) - shift*mpxscl;
  62.         refy = mmpcy(dcmmy(vpdyma) + disp * chrht);
  63.       }
  64.       else if (stindex(side,"LV")!=-1 || stindex(side,"lv")!=-1) {   
  65.         vert = 0;
  66.         refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos);
  67.         refx = mmpcx(dcmmx(vpdxmi) - disp * chrht - shift);
  68.       }
  69.       else if (stindex(side,"RV")!=-1 || stindex(side,"rv")!=-1) {
  70.         vert = 0;
  71.         refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos);
  72.         refx = mmpcx(dcmmx(vpdxma) + disp * chrht - shift);
  73.       }
  74.       else if (strpos(side,'L')!=-1 || strpos(side,'l')!=-1) {   
  75.         vert = 1;
  76.         refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos) - shift*mpyscl;
  77.         refx = mmpcx(dcmmx(vpdxmi) - disp * chrht);
  78.       }
  79.       else if (strpos(side,'R')!=-1 || strpos(side,'r')!=-1) {
  80.         vert = 1;
  81.         refy = dcpcy(vpdymi + (vpdyma-vpdymi) * pos) - shift*mpyscl;
  82.         refx = mmpcx(dcmmx(vpdxma) + disp * chrht);
  83.       }
  84.       else {
  85.         sclp(clpxmi,clpxma,clpymi,clpyma);
  86.         return;
  87.       }
  88.  
  89.       if (vert != 0) {
  90.         xform[0] = 0.0;
  91.         xform[1] = -1.0;
  92.         xform[2] = 1.0;
  93.         xform[3] = 0.0;
  94.       }
  95.       else {
  96.         xform[0] = 1.0;
  97.         xform[1] = 0.0;
  98.         xform[2] = 0.0;
  99.         xform[3] = 1.0;
  100.       }
  101.       plstr(0,xform,refx,refy,text);
  102.       sclp(clpxmi,clpxma,clpymi,clpyma);
  103. }
  104.